package com.zhiyou100.controller.Logistics;

import com.zhiyou100.dao.Impl.LogisticsDaoImpl;
import com.zhiyou100.emtity.Logistics;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

/**
 * @description:
 * @author: 马跃
 * @create: 2021-01-21 13:09
 **/
@WebServlet("/logisticsAdd")
public class LogisticsAddServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        Logistics logistics = new Logistics();
        String address = request.getParameter("sf") + request.getParameter("cs");
        logistics.setL_nativePlace(address);
        try {
            BeanUtils.populate(logistics, request.getParameterMap());
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        new LogisticsDaoImpl().add(logistics);
        request.getRequestDispatcher("/logisticsQueryAll").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
